<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>图书管理</title>
  <style>
    /* 页面基础样式 */
    body {
      font-family: Arial, sans-serif;
      background-color: #f7f7f7;
      margin: 0;
      padding: 0;
    }

    .container {
      max-width: 1200px;
      margin: 30px auto;
      padding: 20px;
      background-color: white;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
      border-radius: 8px;
    }

    h2 {
      color: #333;
      text-align: center;
      margin-bottom: 20px;
    }

    h3 {
      color: #333;
      margin-top: 30px;
    }

    table {
      width: 100%;
      border-collapse: collapse;
      margin-top: 20px;
    }

    th, td {
      padding: 12px;
      text-align: center;
      border: 1px solid #ddd;
      font-size: 16px;
    }

    th {
      background-color: #4CAF50;
      color: white;
    }

    tr:nth-child(even) {
      background-color: #f9f9f9;
    }

    tr:hover {
      background-color: #f1f1f1;
    }

    a {
      color: #007BFF;
      text-decoration: none;
      padding: 6px 12px;
      border-radius: 4px;
      transition: background-color 0.3s;
    }

    a:hover {
      background-color: #ddd;
    }

    .action-buttons {
      display: flex;
      justify-content: center;
      gap: 15px;
    }

    /* 添加新图书按钮样式 */
    .add-book {
      text-align: center;
      margin-top: 20px;
    }

    .footer {
      text-align: center;
      margin-top: 30px;
      font-size: 14px;
      color: #888;
    }

    .footer a {
      color: #007BFF;
      text-decoration: none;
    }

    .footer a:hover {
      text-decoration: underline;
    }
  </style>
</head>
<body>

<div class="container">
  <h2>图书列表</h2>

  <!-- 图书列表 -->
  <table>
    <thead>
    <tr>
      <th>图书ID</th>
      <th>图书名称</th>
      <th>图书类别</th>
      <th>作者</th>
      <th>出版社</th>
      <th>语言</th>
      <th>价格</th>
      <th>出版日期</th>
      <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <!-- 使用 JSTL 循环遍历图书列表 -->
    <c:forEach items="${books}" var="book">
      <tr>
        <td>${book.bookId}</td>
        <td>${book.bookName}</td>
        <td>${book.category}</td>
        <td>${book.author}</td>
        <td>${book.publisher}</td>
        <td>${book.language}</td>
        <td>${book.price}</td>
        <td>${book.publish_date}</td>
        <td class="action-buttons">
          <!-- 编辑链接 -->

          <a href="BooksEdit?bookId=${book.bookId}">编辑</a> |
          <!-- 删除链接 -->
          <a href="BooksDelete?bookId=${book.bookId}">删除</a>
        </td>
      </tr>
    </c:forEach>
    </tbody>
  </table>

  <!-- 添加新图书链接 -->
  <div class="add-book">
    <a href="addBookPage.jsp">添加新图书</a>
  </div>
</div>

<!-- 页脚 -->
<div class="footer">
  <p>&copy; 2024 图书管理系统</p>
</div>

</body>
</html>
